package com.magicalcoder.youyamvc.app.goods.dao.impl;

import com.magicalcoder.youyamvc.app.model.defined.IntegerDate;
import com.magicalcoder.youyamvc.app.model.defined.IntegerObject;
import com.magicalcoder.youyamvc.app.goods.dao.GoodsDao;
import com.magicalcoder.youyamvc.app.model.Goods;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
* 代码为自动生成 Created by www.magicalcoder.com
* 如果你改变了此类 read 请将此行删除
* 欢迎加入官方QQ群:323237052
*/

@Component("goodsDao")
public class GoodsDaoImpl   implements GoodsDao {

    @Resource(name="sqlSessionTemplate")
    private  SqlSessionTemplate  sqlSessionTemplate;
    @Override
    public Goods getGoods(Map<String, Object> query) {
        return sqlSessionTemplate.selectOne("GoodsMapper.getGoods",query);
    }
    @Override
    public List<Goods> getGoodsList(Map<String, Object> query) {
        return sqlSessionTemplate.selectList("GoodsMapper.getGoodsList", query);
    }
    @Override
    public Integer getGoodsListCount(Map<String, Object> query) {
        return sqlSessionTemplate.selectOne("GoodsMapper.getGoodsListCount", query);
    }

    @Override
    public void batchInsertGoods(List<Goods> list) {
        sqlSessionTemplate.insert("GoodsMapper.batchInsertGoods",list);
    }

    @Override
    public void batchReplaceGoods(List<Goods> list) {
        sqlSessionTemplate.insert("GoodsMapper.batchReplaceGoods",list);
    }

    @Override
    public void batchUpdateGoods(List<Goods> list) {
        sqlSessionTemplate.update("GoodsMapper.batchUpdateGoods",list);
    }

    @Override
    public     Long  insertGoods(Goods entity) {
        sqlSessionTemplate.insert("GoodsMapper.insertGoods",entity);
  return entity.getId();    }

    @Override
    public     Long  replaceGoods(Goods entity) {
        sqlSessionTemplate.insert("GoodsMapper.replaceGoods",entity);
  return entity.getId();    }

    @Override
    public void updateGoods(Goods entity) {
        sqlSessionTemplate.update("GoodsMapper.updateGoods", entity);
    }
    @Override
    public void updateGoodsWithoutNull(Goods entity) {
        sqlSessionTemplate.update("GoodsMapper.updateGoodsWithoutNull", entity);
    }
    @Override
    public void updateGoodsByWhereSql(Map<String,Object> entity) {
        sqlSessionTemplate.update("GoodsMapper.updateGoodsByWhereSql", entity);
    }
    @Override
    public void truncateGoods() {
        sqlSessionTemplate.delete("GoodsMapper.truncateGoods");
    }
    @Override
    public void deleteGoods(Map<String, Object> query) {
        sqlSessionTemplate.delete("GoodsMapper.deleteGoods",query);
    }
    @Override
    public void deleteGoodsList(Map<String, Object> query) {
        sqlSessionTemplate.delete("GoodsMapper.deleteGoodsList",query);
    }
    @Override
    public void deleteGoodsByWhereSql(Map<String, Object> query) {
        sqlSessionTemplate.delete("GoodsMapper.deleteGoodsByWhereSql",query);
    }
    @Override
    public void batchDeleteGoods(List<Long> list) {
        sqlSessionTemplate.delete("GoodsMapper.batchDeleteGoods",list);
    }
    @Override
    public void batchDeleteGoodsList(List<Goods> list) {
        sqlSessionTemplate.delete("GoodsMapper.batchDeleteGoodsList",list);
    }

    @Override
    public List<IntegerDate> statisticsDateCountList(Map<String, Object> query) {
    return sqlSessionTemplate.selectList("GoodsMapper.statisticsDateCountList", query);
    }

    @Override
    public List<IntegerDate> statisticsDateIntervalList(Map<String, Object> query) {
        return sqlSessionTemplate.selectList("GoodsMapper.statisticsDateIntervalList", query);
    }

    @Override
    public List<IntegerObject> statisticsGroupList(Map<String, Object> query) {
        return sqlSessionTemplate.selectList("GoodsMapper.statisticsGroupList", query);
    }
}
